//
//  ZhuihaoTabBarController.m
//  SSC
//
//  Created by 红沙尘 on 2017/9/6.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "ZhuihaoTabBarController.h"
#import "ZhuihaojiluVC.h"
@interface ZhuihaoTabBarController ()

@end

@implementation ZhuihaoTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabBar.hidden = YES;
    
    UIButton *left = [self leftButtonWithImageNamed:@"public_back" action:@selector(back)];
    self.navigationItem.leftBarButtonItem = CUSTOMVIEW(left);
    
    self.viewControllers = @[[[ZhuihaojiluVC alloc] initWithType:CaipiaoTypeShishicai title:@"重庆时时彩"],
                             [[ZhuihaojiluVC alloc] initWithType:CaipiaoTypeFenfencai title:@"两分彩"]];
    
    self.navigationItem.titleView = [self myTitleView];
}

- (UIView *)myTitleView {
    
    UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
    
    UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"重庆时时彩",@"两分彩"]];
    segment.frame = CGRectMake(0, 7, 200, 30);
    [titleView addSubview:segment];
    segment.tintColor = [UIColor whiteColor];
    segment.selectedSegmentIndex = 0;
    [segment addTarget:self action:@selector(segmentDidChanged:) forControlEvents:UIControlEventValueChanged];
    
    return titleView;
}

- (void)segmentDidChanged:(UISegmentedControl *)segment {
    self.selectedIndex = segment.selectedSegmentIndex;
}

- (void)back {
    [self.navigationController popViewControllerAnimated:YES];
}


- (UIButton *)leftButtonWithImageNamed:(NSString *)imageNamed action:(SEL)action {
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
    [btn setImage:LoadImage(imageNamed) forState:UIControlStateNormal];
    btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [btn addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
    return btn;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
